﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FormFiller
{
    public partial class MemberInfoChange : Form
    {
        //Ссылка на пользователя, данные которого будем менять.
        public MemberInfo memberInfo;

        public MemberInfoChange(MemberInfo mInfo)
        {
            InitializeComponent();
            this.FormClosed += formClosedHandler;

            memberInfo = mInfo;

            //заполним данные
            fillData();
        }

        private void fillData()
        {
            txtFIO.Text = memberInfo.fio;
            dtpBirthday.Value = memberInfo.birthDay;
            txtQualification.Text = memberInfo.qualification;
            txtPassportData.Text = memberInfo.passportData;
            txtPhone.Text = memberInfo.phone;
            txtEmail.Text = memberInfo.email;
        }

        protected void formClosedHandler(object sender, EventArgs e)
        {
            //сохраняем даннные в объект
            memberInfo.fio = txtFIO.Text;
            memberInfo.birthDay = dtpBirthday.Value;
            memberInfo.qualification = txtQualification.Text;
            memberInfo.passportData = txtPassportData.Text;
            memberInfo.phone = txtPhone.Text;
            memberInfo.email = txtEmail.Text;
        }
    }
}
